package com.easyedu.core.dao;

import com.easyedu.core.entity.po.OpenCourseTime;
import java.util.List;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Select;

/**
 * @author lmr
 **/
@Mapper
public interface OpenCourseTimeDao {

     /**
      * 根据年级和学期查询课表
      * @param openYear 开课年
      * @param semester 开课学期
      * @return 课表列表
      */
     @Select("select * from open_course_time where open_year = #{openYear} and semester = #{semester}")
     List<OpenCourseTime> getByOpenYearAndSemester(int openYear, String semester);

     /**
      * 拷贝中间课表到完整课表
      * @param versionId 课表版本id
      * @return 成功条数
      */
     @Select("insert into open_course_time (open_courses_id, open_year, semester, open_institute_id, open_institute_name,"
             + "teach_institute_id, teach_institute_name, open_department_id,"
             + "open_department_name, course_code, course_number, course_name, credit,"
             + "open_week, open_lesson, open_day, classroom)"
             + "SELECT open_courses_id,open_year,semester,"
             + " open_institute_id,open_institute_name,teach_institute_id,"
             + " teach_institute_name,open_department_id,open_department_name,"
             + " course_code,course_number,course_name,credit,"
             + " open_week,open_lesson,open_day,classroom "
             + "from open_course_time_mid where open_course_time_mid_version_id = #{versionId}")
     Integer getTimeTableFromMid(String versionId);

     /**
      * 删除课表
      * @param openYear
      * @param semester
      * @return
      */
     @Delete("delete from open_course_time where open_year = #{openYear} and semester = #{semester}")
     Integer deleteByYearAndSemester(String openYear, String semester);
}
